<?php
$base_columns = [

    [
        "field" => "biotope_id"
        , "type" => "int"
        , "rules" => "required|integer"
        , "required" => 1
        , "description" => "项目ID"
    ],
    [
        "field" => "biotope_name"
        , "type" => "varchar"
        , "rules" => "max:64"
        , "required" => 0
        , "description" => "项目名称"
    ],
    [
        "field" => "type_id"
        , "type" => "int"
        , "rules" => "required|integer"
        , "required" => 1
        , "description" => "参考字典表 biotope.type"
    ],
    [
        "field" => "batch_id"
        , "type" => "int"
        , "rules" => "required|integer"
        , "required" => 1
        , "description" => "导入批次ID"
    ],
    [
        "field" => "import_status_id"
        , "type" => "tinyint"
        , "rules" => "required|integer"
        , "required" => 1
        , "description" => "导入状态ID,dic import.status"
    ],
    [
        "field" => "status_id"
        , "type" => "tinyint"
        , "rules" => "required|integer"
        , "required" => 1
        , "description" => "状态ID,dic biotope.status"
    ],
    [
        "field" => "district_id"
        , "type" => "int"
        , "rules" => "required|integer"
        , "required" => 1
        , "description" => "所属区"
    ],
    [
        "field" => "street"
        , "type" => "varchar"
        , "rules" => "max:64"
        , "required" => 0
        , "description" => "所在街道"
    ],
    [
        "field" => "city_id"
        , "type" => "int"
        , "rules" => "required|integer"
        , "required" => 1
        , "description" => "所在城市"
    ],
    [
        "field" => "address"
        , "type" => "varchar"
        , "rules" => "max:200"
        , "required" => 0
        , "description" => "地址"
    ],
    [
        "field" => "latitude"
        , "type" => "decimal"
        , "rules" => "numeric"
        , "required" => 0
        , "description" => "纬度"
    ],
    [
        "field" => "longitude"
        , "type" => "decimal"
        , "rules" => "numeric"
        , "required" => 0
        , "description" => "经度"
    ],
    [
        "field" => "scale"
        , "type" => "int"
        , "rules" => "integer"
        , "required" => 0
        , "description" => "地图缩放大小"
    ],
    [
        "field" => "label"
        , "type" => "varchar"
        , "rules" => "max:64"
        , "required" => 0
        , "description" => "地理位置信息"
    ],
    [
        "field" => "proposal_year"
        , "type" => "int"
        , "rules" => "integer"
        , "required" => 0
        , "description" => "立项年份"
    ],
    [
        "field" => "land_area"
        , "type" => "int"
        , "rules" => "integer"
        , "required" => 0
        , "description" => "占地面积 (m2) "
    ],
    [
        "field" => "green_area"
        , "type" => "int"
        , "rules" => "integer"
        , "required" => 0
        , "description" => "绿化面积 (m2) "
    ],
    [
        "field" => "cell_subsidy"
        , "type" => "int"
        , "rules" => "integer"
        , "required" => 0
        , "description" => "补助标准 (元) "
    ],
    [
        "field" => "building_numbers_exp"
        , "type" => "varchar"
        , "rules" => "max:500"
        , "required" => 0
        , "description" => "楼层编号表达式,如:1-5"
    ],
    [
        "field" => "building_numbers"
        , "type" => "varchar"
        , "rules" => "max:2000"
        , "required" => 0
        , "description" => "楼层编号,1,2,3,4,5"
    ],
    [
        "field" => "building_count"
        , "type" => "int"
        , "rules" => "required|integer"
        , "required" => 1
        , "description" => "楼宇数量，统计字段"
    ],
    [
        "field" => "room_count"
        , "type" => "int"
        , "rules" => "required|integer"
        , "required" => 1
        , "description" => "房间数量，统计字段"
    ],
    [
        "field" => "living_percent"
        , "type" => "decimal"
        , "rules" => "required|numeric"
        , "required" => 1
        , "description" => "入住率，统计字段"
    ],
    [
        "field" => "created_by"
        , "type" => "varchar"
        , "rules" => "max:32"
        , "required" => 0
        , "description" => "创建人"
    ],
    [
        "field" => "created_at"
        , "type" => "timestamp"
        , "rules" => "date"
        , "required" => 0
        , "description" => "创建时间"
    ],
    [
        "field" => "updated_by"
        , "type" => "varchar"
        , "rules" => "max:32"
        , "required" => 0
        , "description" => "最后修改人"
    ],
    [
        "field" => "updated_at"
        , "type" => "timestamp"
        , "rules" => "date"
        , "required" => 0
        , "description" => "最后修改时间"
    ],

];

return [
    "group" => "default",
    "controller" => "App\\Http\\Controllers\\BiotopeController",
    "description" => "biotope 基本接口",
    "resource" => "biotope",
    "methods" => [
        [
            "middleware" => ["oauth"],
            "method" => "grid",
            "privileges" => ["biotope.view"],
            "requestRoute" => "/biotope/grid",
            "description" => "管理 biotope",
            "inputs" => [
                [
                    "field" => "page"
                    , "rules" => "numeric"
                    , "description" => "页码（第几页），默认为1"
                ],
                [
                    "field" => "page_size"
                    , "rules" => "numeric"
                    , "description" => "翻页大小，默认=10"
                ]
            ],
            "outputs" => $base_columns,
            "errors" => [
            ]
        ],
        [
            "middleware" => ["oauth"],
            "method" => "edit",
            "privileges" => ["biotope.edit"],
            "requestRoute" => "biotope/edit",
            "description" => "创建 biotope",
            "inputs" => $base_columns,
            "outputs" => $base_columns,
            "errors" => [
            ]
        ],
        [
            "middleware" => ["oauth"],
            "method" => "detail",
            "privileges" => ["biotope.view"],
            "requestRoute" => "biotope/detail",
            "description" => "获取 biotope",
            "inputs" => [
            ],
            "outputs" => $base_columns,
            "errors" => [
                [
                    "code" => "record.not.found"
                    , "message" => "没有找到记录"
                ]
            ]
        ],
        [
            "middleware" => ["oauth"],
            "method" => "delete",
            "privileges" => ["biotope.kill"],
            "requestRoute" => "biotope/delete",
            "description" => "删除 biotope",
            "inputs" => [
                [
                    "field" => "biotope_id"
                    , "type" => ""
                    , "rules" => "required|integer"
                    , "required" => 1
                    , "description" => ""
                ],
            ],
            "outputs" => [
            ],
            "errors" => [
                [
                    "code" => "record.used"
                    , "message" => "记录已经被使用，存在重要数据，无法删除"
                ]
            ]
        ]
    ]
];